/*
 *  Copyright (C) 2022  贺龙宇
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
#ifndef LOG_H
#define LOG_H
#include<unistd.h>
#include <termios.h>
#include <fcntl.h>
#include<string>
#include<cstring>
#include<ctime>
#include<iostream>
#include"../define.h"

#define LOG_DEFAULT 0
#define LOG_SELECT 1
#define LOG_TFLUNA 2
#define LOG_SERIAL_PORT 3
#define LOG_ERROR 4



class Log{
public:
  Log();
  ~Log();
  void Init(); //初始化
  void writeLog(const std::string&str, int log_type=LOG_DEFAULT); //写日志
private:
  inline void String2Char(char*,const std::string&);
  int program_start_time;
  std::string file_name;
  std::string log_type[5];
};



std::string Float2String(const float&, int =2);//将float类型转化为string类型



extern Log *FYTLog;

#endif // LOG_H

